const { Model, DataTypes } = require('sequelize');

const sequelize = require('./database');
const Match = require('./match');

class Project extends Model {}

Project.init({
  projectName: { // 赛项名称
    type: DataTypes.STRING,
    allowNull: false,
    unique: true
  },
  projectPersonCount: { // 赛项参赛队伍人数（1人赛，多人赛等）
    type: DataTypes.INTEGER,
    allowNull: true,
    unique: false
  },
  matchId: {
    type: DataTypes.INTEGER,  //比赛名称
    allowNull: false,
    references: {
      model: Match, // 指定关联的模型
      key: 'id'
    }
  }
}
, {
  sequelize,
  modelName: 'project'
});
Project.belongsTo(Match,{ foreignKey: 'matchId' })



module.exports = Project;